<template>
  <el-container class="home-container">
    <el-header class="header">
      <el-space justify="space-between" alignment="center">
        <h1 class="logo">服务系统</h1>
        <el-space>
          <el-button type="text" @click="startService">开始服务</el-button>
          <el-button type="text" @click="queryOrder">查询订单</el-button>
          <el-button type="primary" plain>登录</el-button>
        </el-space>
      </el-space>
    </el-header>

    <!-- 主要内容区 -->
    <el-main class="content">
      <!-- 欢迎标语 -->
      <el-card class="welcome-section">
        <h1>欢迎使用服务系统</h1>
        <span class="el-text--secondary">专业、高效、安全的服务平台</span>
        
        <!-- 功能按钮 -->
        <div class="button-group">
          <el-button 
            type="primary" 
            size="large"
            @click="startService"
          >
            开始服务
          </el-button>
          <el-button 
            type="info" 
            size="large"
            @click="queryOrder"
          >
            查询订单
          </el-button>
        </div>
      </el-card>

      <!-- 服务展示 -->
      <el-card class="service-section">
        <template #header>
          <span>热门服务</span>
        </template>
        <el-empty
          v-if="services.length === 0"
          description="暂无服务数据"
          class="empty-state"
        >
          <template #extra>
            <el-button size="small" @click="refreshServices">
              刷新数据
            </el-button>
          </template>
        </el-empty>
        
        <el-row :gutter="12" v-else>
          <el-col :xs="24" :sm="12" :md="8" :lg="6" v-for="service in services" :key="service.id">
            <el-card :body-style="{ padding: '0px' }" shadow="hover">
              <img :src="service.image" class="service-image">
              <div style="padding: 14px;">
                <h3>{{ service.name }}</h3>
                <span class="el-text--secondary">{{ service.description }}</span>
                <div class="bottom">
                  <el-button type="primary" @click="startService">立即使用</el-button>
                </div>
              </div>
            </el-card>
          </el-col>
        </el-row>
      </el-card>
    </el-main>

    <!-- 页脚 -->
    <el-footer class="footer">
      <el-space direction="vertical" alignment="center">
        <span class="el-text--secondary">© 2023 服务系统 版权所有</span>
        <el-space>
          <el-button type="text">关于我们</el-button>
          <el-button type="text">联系方式</el-button>
                      <el-button type="text">帮助中心</el-button>
        </el-space>
      </el-space>
    </el-footer>
  </el-container>
</template>

<script setup>
import { 
  ElContainer,
  ElHeader,
  ElMain,
  ElFooter,
  ElSpace,
  ElButton,
  ElCard,
  ElRow,
  ElCol,
  ElEmpty
} from 'element-plus'
import { useRouter } from 'vue-router'
import { ref } from 'vue'

const router = useRouter()

const startService = () => {
  router.push('/service')
}

const queryOrder = () => {
  router.push('/query')
}

// 刷新服务数据
const refreshServices = () => {
  services.value = [
    {
      id: 1,
      name: 'VIP专属服务',
      description: '尊享VIP专属通道和特权',
      image: 'https://iph.href.lu/450x200?text=%E5%9B%BE%E7%89%87%E5%9C%A8%E5%81%9A%E5%95%A6&fg=666666&bg=cccccc'
    },
    {
      id: 2,
      name: '标准服务套餐',
      description: '满足日常需求的基础服务',
      image: 'https://iph.href.lu/450x200?text=%E5%9B%BE%E7%89%87%E5%9C%A8%E5%81%9A%E5%95%A6&fg=666666&bg=cccccc'
    }
  ]
}

// 服务数据
const services = ref([
  {
    id: 1,
    name: 'VIP专属服务',
    description: '尊享VIP专属通道和特权',
    image: 'https://iph.href.lu/450x200?text=%E5%9B%BE%E7%89%87%E5%9C%A8%E5%81%9A%E5%95%A6&fg=666666&bg=cccccc'
  },
  {
    id: 2,
    name: '标准服务套餐',
    description: '满足日常需求的基础服务',
    image: 'https://iph.href.lu/450x200?text=%E5%9B%BE%E7%89%87%E5%9C%A8%E5%81%9A%E5%95%A6&fg=666666&bg=cccccc'
  },
  {
    id: 3,
    name: '企业定制服务',
    description: '为企业量身定制的解决方案',
    image: 'https://iph.href.lu/450x200?text=%E5%9B%BE%E7%89%87%E5%9C%A8%E5%81%9A%E5%95%A6&fg=666666&bg=cccccc'
  },
  {
    id: 4,
    name: '紧急加急服务',
    description: '24小时快速响应处理',
    image: 'https://iph.href.lu/450x200?text=%E5%9B%BE%E7%89%87%E5%9C%A8%E5%81%9A%E5%95%A6&fg=666666&bg=cccccc'
  }
])
</script>

<style scoped>
.home-container {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.header {
  padding: 0 24px;
  height: 64px;
  display: flex;
  align-items: center;
}

.logo {
  margin: 0;
  color: #18a058;
}

.content {
  padding: 24px;
  flex: 1;
}

.welcome-section {
  text-align: center;
  margin-bottom: 24px;
}

.button-group {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  justify-content: center;
  margin-top: 24px;
}

.service-section {
  margin-bottom: 24px;
}

.service-image {
  width: 100%;
  height: 160px;
  object-fit: cover;
}

.empty-state {
  padding: 40px 0;
  text-align: center;
}

.empty-state .n-empty {
  margin: 0 auto;
}

.footer {
  padding: 24px;
  text-align: center;
}

/* 响应式设计 */
@media (max-width: 768px) {
  .header {
    padding: 0 12px;
    height: 56px;
  }
  
  .content {
    padding: 12px;
  }
  
  .button-group {
    flex-direction: column;
    width: 100%;
  }
  
  .button-group .n-button {
    width: 100%;
  }
}
</style>